import json

# 读取原始文件
with open('d:/YXT_Project/llama-factory-experiments/data/train_cf.json', 'r', encoding='utf-8') as f:
    data = json.load(f)

# 处理列表中的每个项目
results = []
for item in data:
    result = {
        "instruction": "判断输入内容是否属于或包含于小戈的'个人经历'且不包含'卖货'内容",
        "input": item.get("output", ""),
        "output": "FALSE" if "##卖货##" in item.get("tags", []) else "TRUE"
    }
    results.append(result)

# 写入新文件
with open('d:/YXT_Project/llama-factory-experiments/data/extracted_data.json', 'w', encoding='utf-8') as f:
    json.dump(results, f, ensure_ascii=False, indent=2)

print("数据处理完成，结果已保存到extracted_data.json")